/**
 * Created by Administrator on 2017/7/7.
 */
define(function(require, exports){
	// 自定义列表
	exports.onMain = function(boot,data,app){
		if(!app.routerValid('')) {
			return;
		}
		var title = LANG('自定义报表');
		var con = app.getContainer({
			scenes: 'main',
			full: false,
			sitelist: false,
			setup_btn: false,
			title: LANG('自定义报表'),
			type: 'sidebar'
		});
		con.createBusiness(data.name + '_bar', 'layout/navbar.base', {
			'contentType': 'info',
			'autoBuild': true,
			'data': data,
			'addTitle': title,
			'type': 'report'
		}, function(mod, created){
			if(mod){
				mod.setData(data, title);
			}
		});
		con.createBusiness(data.name, 'report/action/list.customReport', {
		}, function(mod, created){
			if(created){
				mod.reload();
			}
		});
	};
	// 新建报表
	exports.onEdit = function(boot, data, app){
		// todo权限判断
		var id = +data.param;
		var title = id ? LANG('编辑报表') : LANG('新建报表');

		var con = app.getContainer({
			scenes: 'main',
			full: false,
			sitelist: false,
			setup_btn: false,
			title: title,
			type: 'scroll'
		});

		con.createBusiness(data.name + '_bar', 'layout/navbar.base', {
			'contentType': 'info',
			'autoBuild': true,
			'data': data,
			'addTitle': title,
			'type': ''
		}, function(mod, created){
			if(mod){
				mod.setData(data, title);
			}
		});

		con.createBusiness(data.name, 'report/action/edit.base', {
		}, function(mod){
			mod.reset();
			if (id) {
				mod.load(id);
			}
		});
	}
	// 另存为
	exports.onSaveAs = function(boot, data, app){
		// todo权限判断
		var id = +data.param;
		var title = LANG('新建报表');
		var con = app.getContainer({
			scenes: 'main',
			full: false,
			sitelist: false,
			setup_btn: false,
			title: title,
			type: 'scroll'
		});
		con.createBusiness(data.name + '_bar', 'layout/navbar.base', {
			'contentType': 'info',
			'autoBuild': true,
			'data': data,
			'addTitle': title,
			'type': ''
		}, function(mod, created){
			if(mod){
				mod.setData(data, title);
			}
		});
		con.createBusiness(data.name, 'report/action/edit.base', {
		}, function(mod){
			mod.reset();
			if (id) {
				mod.load(id,true);
			}
		});
	}
});